#

| Chapter 21 More About Managing Files |

## 21.14 Automatically Appending the Date to a Filename

I suppose this falls into the category of "stupid tricks" but I still find it useful sometimes. I created a simple alias called vid, which I use to create and edit a file with a date as part of the filename.

I find it handy for repetitive reports and memos.

The alias looks like this:

>     alias vid "vi \!:1.`date +%m.%d`"

and given an argument like memo or status, appends the date as an extension. Using wildcards, I can then list all my memos of a particular date or a particular subject:

>     % ls status*
>     status.02.18
>     status.03.10
>     % ls *3.10
>     budget.03.10
>     status.03.10

If I wanted to add the year, I'd put a dot or other separator, followed by `%y` in the specification to the date command.

If you understand backquote interpolation (9.16) and the formats for the date (51.10) command, you can easily develop variations of this alias that work with other commands besides vi.

- TOR

21.13 Read an Inode with stat |  | 22. File Security, Ownership, and Sharing